#include "stdafx.h"
#include "HierachyComponent.h"


namespace Be
{
	HierachyComponent::HierachyComponent(Entity* p_pEntity)
		: Component(p_pEntity)
		, m_pParent(0)
	{
	}

	HierachyComponent::~HierachyComponent()
	{
	}

	void HierachyComponent::SetParent(ComPtr<HierachyComponent> l_pParent)
	{
		m_pParent = l_pParent;
	}

	ComPtr<HierachyComponent> HierachyComponent::GetParent()
	{
		return m_pParent;
	}

	void HierachyComponent::AddChild(ComPtr<HierachyComponent> p_pChild)
	{
		assert(p_pChild != 0);
		assert(m_pChildSet.find(p_pChild) == m_pChildSet.end());

		m_pChildSet.insert(p_pChild);
	}

	void HierachyComponent::RemoveChild(ComPtr<HierachyComponent> p_pChild)
	{
		assert(p_pChild != 0);

		std::set<ComPtr<HierachyComponent>>::iterator l_Iter = m_pChildSet.find(p_pChild);
		assert(l_Iter != m_pChildSet.end());

		m_pChildSet.erase(l_Iter);
	}

	std::set<ComPtr<HierachyComponent>>& HierachyComponent::GetChildSet()
	{
		return m_pChildSet;
	}
}